package com.example.leetdemo.finash;

public class Solution122 {

    public int maxProfit(int[] prices) {
        int max = 0, price = prices[0];
        for (int i = 1; i < prices.length; i++) {
            if (price <= prices[i]) {
                max += prices[i] - price;
            }
            price = prices[i];
        }
        return max;
    }
}
